package ee.nlp.evn.entities;

import java.util.ArrayList;
import java.util.List;

public class VerbClass {
	private String name;
	private String code;
	private VerbClass parent;
	private List<Verb> members;
	private List<Role> roles;
	private List<Frame> frames;
	public VerbClass(String pName, String pCode) {
		setName(pName);
		setCode(pCode);
		members = new ArrayList<Verb>();
		roles = new ArrayList<Role>();
		frames = new ArrayList<Frame>();
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the code
	 */
	public String getCode() {
		return code;
	}
	/**
	 * @param code the code to set
	 */
	public void setCode(String code) {
		this.code = code;
	}
	/**
	 * @return the parent
	 */
	public VerbClass getParent() {
		return parent;
	}
	/**
	 * @param parent the parent to set
	 */
	public void setParent(VerbClass parent) {
		this.parent = parent;
	}
	/**
	 * @return the members
	 */
	public List<Verb> getMembers() {
		return members;
	}
	/**
	 * @param members the members to set
	 */
	public void addMember(Verb member) {
		this.members.add(member);
	}
	/**
	 * @return the roles
	 */
	public List<Role> getRoles() {
		return roles;
	}
	/**
	 * @param roles the roles to set
	 */
	public void addRole(Role role) {
		this.roles.add(role);
	}
	/**
	 * @return the frames
	 */
	public List<Frame> getFrames() {
		return frames;
	}
	/**
	 * @param frames the frames to set
	 */
	public void addFrame(Frame frame) {
		this.frames.add(frame);
	}
	public boolean hasMember(String trunk) {
		String m = trunk.split("\\+")[0];
		for (Verb v : members) {
			if (v.getTrunk().equals(m)) {
				return true;
			}
		}
		return false;
	}
	public Verb getMember(String trunk) {
		String m = trunk.split("\\+")[0];
		for (Verb v : members) {
			if (v.getTrunk().equals(m)) {
				return v;
			}
		}
		return null;
	}
	
	public String toString() {
		String result = name + "-" + code + "\n";
		for (Verb m : members) {
			result += m.toString() + "\n";
		}
		return result;
	}
}
